//
//  HYCPushRecommendViewController.m
//  FamilyTravel
//
//  Created by dllo on 15/10/23.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HYCPushRecommendViewController.h"
#import "UMSocialSnsService.h"
#import "UMSocial.h"
#import "HYCHeadDocument.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height



@interface HYCPushRecommendViewController ()<UIWebViewDelegate,UMSocialUIDelegate>
@property(nonatomic, retain) UIWebView *webView;
@property(nonatomic, retain) MBProgressHUD *hud;
@end

@implementation HYCPushRecommendViewController

{
    UIActivityIndicatorView *acView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    
    
    NSURL *url = [NSURL URLWithString:self.str];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];
    [self.webView release];
    self.webView.delegate = self;
    
    
    
    self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.hud.labelText = @"加载中...";
    
   
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 20, 18);
    [button setBackgroundImage:[UIImage imageNamed:@"share.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    

}

- (void)buttonAction:(UIButton *)button{
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"5639b440e0f55aa58000115b"
                                      shareText:self.str
                                     shareImage:[UIImage imageNamed:@"icon"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,nil]
                                       delegate:self];
}


-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的微博平台名
        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
    }
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    self.hud.hidden = YES;
}


//- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
//{
//    NSLog(@"%@", error);
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
